<!DOCTYPE html>
<body>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<style>
.container {
    width: 200px;
    height: 200px;
    overflow: auto;
    border: 1px solid blue;
}

.content {
    background: lime;
}

input {
    display: block;
}
</style>
<div class="container">
<div class="content">
</div>
</div>
<script>
test(function() {
    var content = document.querySelector('.content');
    function refresh() {
        while (content.firstChild)
            content.removeChild(content.firstChild);
        for (var i = 0; i < 100; ++i) {
            var input = document.createElement('input');
            input.type = 'checkbox';
            content.appendChild(input);
        }
    }
    refresh();
    // focus() scrolls the |content|.
    content.lastChild.focus();
    content.offsetTop;
    var scrollTopBeforeRefresh = document.querySelector('.container').scrollTop;
    assert_not_equals(scrollTopBeforeRefresh, 0);

    refresh();
    content.offsetTop;
    assert_equals(scrollTopBeforeRefresh, document.querySelector('.container').scrollTop);
}, "Removing focus should not force to lay out.");
</script>
</body>
